<?php

class Homepage extends MX_Controller {

    function __construct() {
        parent::__construct();
        $this->load->helper('commons');
        $this->load->model('pages/pages_model');
    }

    function index() {
        $current_menu = array('current_menu' => '/' . $this->uri->uri_string());
        $layout = 'layout/main_layout';
        $options = array();
        $view_data = array();

        $lang = switch_language($this->uri->segment(1));
        $options['lang'] = $lang;

        $view_data['main_menu'] = modules::run('menus/menus/get_main_menus', $current_menu);
        $view_data['is_home_page'] = TRUE;

        if (MOBILE_SITE) {
            $view_data['bottom_menus'] = modules::run('menus/menus/get_bottom_menus', $options);
            $layout = 'mobile/main_layout';
        } else {
            $view_data['slide_banner'] = modules::run('advertisements/advertisements/get_advertisements_slide_show');
        }

        $this->load->helper('cache');
        $config = get_cache('configurations');

        $view_data['title'] = $config['meta_title'] . DEFAULT_TITLE_SUFFIX;
        $view_data['keywords'] = $config['meta_keywords'];
        $view_data['description'] = $config['meta_description'];

        $this->load->view($layout, $view_data, FALSE);
    }

    function get_sitemap_xml() {
        $this->load->model('sitemap_model');
        Header('Content-type: text/xml');
        echo $this->sitemap_model->generate_sitemap();
    }

}

?>